#include"ring_queue.hpp"
#include<iostream>
#include<unistd.h>

using namespace std;

void* Pust(void* s)
{
  RingQueue<int>* bq=(RingQueue<int>*)s;
  int i=1;
  while(1)
  {
    sleep(1);
    bq->Put(i);
    cout<<"put "<<i<<endl;    
    i++;
  }
  return nullptr;
}
void* Task(void* s)
{
  RingQueue<int>* bq=(RingQueue<int>*)s;
  int i=0;
  while(1)
  {
    sleep(1);
    bq->Get(&i);
    cout<<"get "<<i<<endl;
  }
  return nullptr;
}
int main()
{
  pthread_t t1,t2,t3,t4;
  RingQueue<int>* bq=new RingQueue<int>(4);
  
  pthread_create(&t1,nullptr,Pust,(void*)bq);
  pthread_create(&t2,nullptr,Pust,(void*)bq);
  pthread_create(&t3,nullptr,Task,(void*)bq);
  pthread_create(&t4,nullptr,Task,(void*)bq);

  pthread_join(t1,nullptr);
  pthread_join(t2,nullptr);
  pthread_join(t3,nullptr);
  pthread_join(t4,nullptr);
  return 0;
}
